Suppose the function f(x) is
defined as
Compute the value of f(x) for a given x.
Input. Each line contains one double value x (x ≥ 1).
Output. For each value x print on a separate line the value f(x) with 6 digits after the
decimal point.
Sample input |
Sample output |
1 2.3 2.56 7.123456 |
10.731685 31.926086 40.762019 3725.231017 |
mathematics
For each real value x, compute the
value of the function f(x). Read the input data till the end of file.
Algorithm
realization
Read the value of
x. Compute the value of the function and print the answer.
while(scanf("%lf",&x)
== 1)
{
y = sin(x) + sqrt(log(3*x) / log(4.0)) +
ceil(3*exp(x));
printf("%.6lf\n",y);
}
Java realization
import java.util.*;
public class Main
{
public static void main(String[] args)
{
Scanner con = new Scanner(System.in);
while(con.hasNextDouble())
{
double x = con.nextDouble();
double y = Math.sin(x) + Math.sqrt(Math.log(3*x) / Math.log(4.0))
+ Math.ceil(3*Math.exp(x));
System.out.printf("%.6f\n",y);
}
con.close();
}
}